import asyncio

from api_utils.base_data_api import BaseDate
from api_utils.selling_list_api import get_selling_listing
from database.models.asin_model import AsinData
from database.models.store_model import StoreData


class AsinOperation:

    def __init__(self):
        pass

    @staticmethod
    def handle_asin_info():
        sid_list = StoreData.get_sid_list()
        base_data = BaseDate()
        for sid in sid_list:
            response = asyncio.run(get_selling_listing(base_data, sid))
            print(response.message)
            if response.message == "success":
                all_asin_data = response.data
                print(sid)
                if sid == 10977:
                    print(all_asin_data)
                print("111111111111111111111111111111111111111")
                # AsinData.insert_asin_info(all_asin_data)
                continue
            else:
                print("获取asin信息失败")
                return False
        return True


if __name__ == '__main__':
    AsinOperation.handle_asin_info()
